const app = getApp()

Page({
  data: {
    statusBar: 0, //状态栏高度
    customBar: 0,
    taps: [{
        name: "热卖",
        type: 1
      },
      {
        name: "美食",
        type: 2
      },
      {
        name: "食材",
        type: 3
      },
      {
        name: "水果",
        type: 4
      },
      {
        name: "服饰",
        type: 5
      },
      {
        name: "百货",
        type: 6
      },
      {
        name: "机械",
        type: 7
      }, {
        name: "数码",
        type: 8
      },
      {
        name: "图书",
        type: 9
      },
      {
        name: "清凉一夏",
        type: 10
      }, {
        name: "宠物",
        type: 11
      }
    ],
    curTap: 1,
    scroolLeft: 0,
    imgUrls: [
      '../../images/goods-test.png',
      '../../images/goods-test.png',
      '../../images/goods-test.png',
    ],
    lables: [{
        img: '../../images/index/cai1.png',
        text: '全球直采'
      },
      {
        img: '../../images/index/cai2.png',
        text: '正品保障'
      },
      {
        img: '../../images/index/cai3.png',
        text: '售后无忧'
      },
      {
        img: '../../images/index/cai4.png',
        text: '假一赔十'
      },
      {
        img: '../../images/index/cai5.png',
        text: '资质与规则'
      },
    ],
    countDownData: [],
    actTime: '2019-08-10 12:37:00', //活动时间
    dataArr: []
  },
  tapSelected: function(e) {
    let that = this;
    let curType = e.currentTarget.dataset.type;
    that.setData({
      curTap: curType,
      scroolLeft: (curType - 1) * 60
    })
  },
  onLoad: function() {
    this.setData({
      dataArr: app.globalData.dataArr
    })

    if (!app.globalData.loginDone) {
      app.wxLogin().then(res => {
        let userBean = res;
        if (userBean) {
          app.globalData.userBean = res;
        }
        app.globalData.loginDone = true
      }).catch(msg => {
        app.globalData.userBean = null;
        app.globalData.loginDone = true
      });
    } else {
      
    }
  },

  toFlash: function() {
    wx.navigateTo({
      url: '../flash-index-list/flash-index-list' // 指定页面的url
    });
  },
  pingGroup: function() {
    wx.navigateTo({
      url: '../ping-group-index/ping-group-index' // 指定页面的url
    });
  },
  toLuckyDetail: function() {
    wx.navigateTo({
      url: '../lucky-detail/lucky-detail' // 指定页面的url
    });
  },
  toPingDetail: function() {
    wx.navigateTo({
      url: '../ping-detail/ping-detail'
    })
  },
  toSearch: function() {
    wx.navigateTo({
      url: "../search-page/index"
    })
  },
  toGoodsDetail: function(e) {
    var type = e.currentTarget.dataset.type;
    wx.navigateTo({
      url: '../goods-detail/goods-detail?type=' + type, // 指定页面的url
    });
  },
  toSecClassify: function() {
    wx.navigateTo({
      url: '../second-classify/second-classify?type=0' // 指定页面的url
    });
  },
  twoAreaDetail: function() {
    wx.navigateTo({
      url: '../twoarea-detail/index' // 指定页面的url
    });
  },
  oneAreaDetail: function() {
    wx.navigateTo({
      url: '../onearea-detail/index' // 指定页面的url
    });
  },
})